# Contributor: psykose <alice@ayaya.dev>
# Maintainer: psykose <alice@ayaya.dev>
pkgname=stylua
pkgver=0.14.0
pkgrel=0
pkgdesc="Opinionated Lua 5.1/5.2/luau code formatter"
url="https://github.com/JohnnyMorganz/StyLua"
arch="all !s390x !riscv64" # blocked by cargo
license="MPL-2.0"
makedepends="cargo"
source="$pkgname-$pkgver.tar.gz::https://github.com/JohnnyMorganz/StyLua/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/StyLua-$pkgver"

prepare() {
	default_prepare
	cargo fetch --locked
}

build() {
	cat >> Cargo.toml <<- EOF
		[profile.release]
		codegen-units = 1
		lto = true
		opt-level = "s"
		panic = "abort"
	EOF
	cargo build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 "$builddir"/target/release/stylua \
		-t "$pkgdir"/usr/bin
}

sha512sums="
ce436bb267008472cc3e237c88d8f0834e0e237c2973bb5e12d69642b3a90f140dc2b5c46f20f8df866df8e89f54b7fdfce06ace8e659969d03cda3300ec25e8  stylua-0.14.0.tar.gz
"
